package com.modnique;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.archive.crawler.datamodel.CandidateURI;
import org.archive.crawler.postprocessor.FrontierScheduler;

public class ModNiqueFrontierScheduler extends FrontierScheduler {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public ModNiqueFrontierScheduler(String name) {
		super(name);
	}
	
	
	String regEx_sale_event = "www\\.modnique\\.com/saleevent/";
	String regEx_product = "www\\.modnique\\.com/product/";
	Pattern pat_sale_event = Pattern.compile(regEx_sale_event);
	Pattern pat_product = Pattern.compile(regEx_product);
	Matcher mat_sale_event = null;
	Matcher mat_product = null;
	
	protected void schedule(CandidateURI caUri) {
		String uri = caUri.toString();
		mat_sale_event = pat_sale_event.matcher(uri);
		mat_product = pat_product.matcher(uri);
		if("dns:www.modnique.com".equals(uri)){
		  getController().getFrontier().schedule(caUri);
		}
		else if(mat_sale_event.find()){
		System.out.println("===="+uri);
		  getController().getFrontier().schedule(caUri);
		}
		else if(mat_product.find()){
			System.out.println("@@@@"+uri);
			  getController().getFrontier().schedule(caUri);
			}
       
    }

}
